package com.winit;

import com.winit.employeInfo.model.Duty;
import com.winit.employeInfo.repository.DutyRepository;
import com.winit.employeeDataExtract.EmployeeDataExtractor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.List;

/**
 * 这个app将佩琪数据（employee/duty/dept）导入特定数据库
 */
//@SpringBootApplication(scanBasePackages = "com.winit")
public class ExtractEmployeeToDbApp {

    public static void main(String[]args) throws Exception{
        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(ExtractEmployeeToDbApp.class, args);
//        List<Dept> deptList = EmployeeDataExtractor.extractDept();
//        DeptRepository deptRepository = configurableApplicationContext.getBean(DeptRepository.class);
//        deptRepository.save(deptList);
//        List<Employee> deptList = EmployeeDataExtractor.extractEmployee();
//        EmployeeRepository deptRepository = configurableApplicationContext.getBean(EmployeeRepository.class);
//        deptRepository.save(deptList);
        List<Duty> deptList = EmployeeDataExtractor.extractDuty();
        DutyRepository deptRepository = configurableApplicationContext.getBean(DutyRepository.class);
        deptRepository.save(deptList);
    }

}
